package com.aier.admin_new.action;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.aier.admin_new.entity.RoleMenus;
import com.aier.admin_new.service.IRoleMenusService;
import com.aier.common.common.CommonSession;
import com.aier.school.entity.School;
import com.aier.school.entity.SchoolTeacher;
import com.aier.school.service.ISchoolService;
import com.aier.school.service.ISchoolTeacherService;

/**
 * 菜单action
 */
@Scope("prototype")
@Component("menusAction")
public class MenusAction extends AdminNewBaseAction {

	private static final long serialVersionUID = 1L;
	@Resource(name = "roleMenusService")
	IRoleMenusService roleMenusService;
	@Resource(name = "schoolService")
	private ISchoolService schoolService;
	@Resource(name = "schoolTeacherService")
	private ISchoolTeacherService schoolTeacherService;
	
	private int s;//1成功；0失败
	private List<RoleMenus> rm;//菜单数据
	private int sid;//学校ID
	private Long tid;// 教师ID
	private long uid ;
	
	@Override
	public String execute() throws Exception {
		School sc = schoolService.searchSchoolByUid(uid);
		sid=sc.getSid();
		SchoolTeacher schoolTeacher = schoolTeacherService.searchSchoolTeacherByIds(uid, sid);
		tid=schoolTeacher.getTid();
		s=1;
		return SUCCESS;
	}
	
	public String getMenus(){
		 rm =roleMenusService.searchRoleMenusByRoletype((String)request.getSession().getAttribute(CommonSession.SESSION_USER_ROLE));
		 s=1;
		 return SUCCESS;
	}

	public int getS() {
		return s;
	}

	public void setS(int s) {
		this.s = s;
	}

	public int getSid() {
		return sid;
	}

	public void setSid(int sid) {
		this.sid = sid;
	}
	public Long getTid() {
		return tid;
	}

	public void setTid(Long tid) {
		this.tid = tid;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}
}